// import { get_image } from '../utils'

const HrDepartment = {
  _description: '部门',
  _name: 'hr.department',
  _fields: {
    name: { type: 'char', string: '名称' },
    complete_name: { type: 'char', string: '全名', compute: true },
    parent_id: {
      type: 'many2one',
      string: '上级部门'
      // fields: { name: null, parent_path: null },
      // filter: ({ record, options }) => {
      //   // console.log('PartnerCategory,', record, options)
      //   // parent_id 不能选自己, 不能选儿孙
      //   return options.filter(item => {
      //     const parent_path = item.object.parent_path
      //       .split('/')
      //       .map(item => Number(item))

      //     return item.value !== record.id && !parent_path.includes(record.id)
      //   })
      // }
    },
    manager_id: { type: 'many2one', string: '部门经理' },
    member_ids: {
      type: 'one2many',
      relation: 'hr.employee',
      string: '员工'
    },

    jobs_ids: {
      type: 'one2many',
      relation: 'hr.job',
      string: '职位'
    },
    child_ids: {
      type: 'one2many',
      relation: 'hr.department',
      string: '下级部门'
    },

    note: { type: 'text', string: '备注' }
  },
  metadata: {
    propForView: {
      fields: {
        name: null,
        parent_id: null,
        manager_id: null
      }
    }
  }
}

const HrJob = {
  _description: '职位',
  _name: 'hr.job',
  _fields: {
    name: { type: 'char', string: '名称' },
    department_id: { type: 'many2one', string: '部门' },
    no_of_recruitment: { type: 'integer', string: '期望的新员工' },

    description: { type: 'text', string: '工作说明' }
  }
}

const Models = {
  'hr.department': HrDepartment,
  'hr.job': HrJob
}

export default Models
